<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
    <meta name="Author" content="geovindu,geovindu"/>
    <meta name="Description" content="汉字转拼音"/>
    <meta name="keyword" content="Keywords"/>
    <meta name="generator" content="geovindu"/>
    <meta name="robots" content="NOINDEX,NOFOLLOW"/>
    <meta name="googlebot" content="NOARCHIVE, NOODP, NOSNIPPET"/>
    <meta name="slurp" content="NOARCHIVE, NOYDIR, NOSNIPPET"/>
    <meta http-equiv="expires" content="Tue, 20 Aug 1996 14:25:27 GMT"/>
    <link rel="shortcut icon" href="favicon.ico" type="image/x-icon"/>
    <link rel="icon" href="favicon.ico" type="image/ico"/>
    <link rel="bookmark" href="favicon.ico"/>
    <link rel="home" title="Home" href="http://www.dusystem.com"/>
    <title>javascript 汉字转拼音</title>
    <script src="zepto.js"></script>
    <script src="character.js"></script>
</head>

<body>
<script>
    $(function () {
        var data = [{name: "顺丰快递"},{name: "圆通快递"},{name: "韵达快递"},{name: "天天快递"},{name: "中通快递"},{name: "申通快递"},{name: "申啊快递"}];
        for(var i = 0; i < data.length; i++){
            var _pinyin = pinyin.go(data[i].name);
            data[i].pinyin = _pinyin;
            data[i].firstCharacter = _pinyin.charAt(0);
        }
        //定义一个比较器
        function compare(propertyName) {
            return function(object1, object2) {
                var value1 = object1[propertyName];
                var value2 = object2[propertyName];
                if (value2 < value1) {
                    return 1;
                } else if (value2 > value1) {
                    return -1;
                } else {
                    return 0;
                }
            }
        }

        data.sort(compare("pinyin"));
        console.log(data);
    })
</script>
</body>

</html>
